package com.suixun.service.mongodb;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import com.suixun.dao.mongodb.UserCacheDao;
import com.suixun.entity.mongodb.UserCache;
import com.suixun.util.db.MongoDBPagination;

@Service("userCacheService")
public class UserCacheService {

	@Resource(name = "userCacheDao")
	private UserCacheDao userCacheDao;

	public UserCache findByid(int id) {
		return userCacheDao.findById(id);
	}

	public UserCache findOne(Map<String, String> params) {
		return this.userCacheDao.findOne(params);
	}

	public List<UserCache> find(Query query) {
		return this.userCacheDao.find(query);
	}

	public UserCache save(UserCache bean) {
		return userCacheDao.save(bean);
	}

	public MongoDBPagination<UserCache> getPageArticle(int pageNo, int pageSize) {
		return userCacheDao.getPageArticle(pageNo, pageSize);
	}

	/**
	 * 暂时只是固定去修改,会有下一篇博客,写高级修改...
	 */
	public void update(String id, Map<String, String> params) {
		this.userCacheDao.updateEntity(id, params);
	}

	public UserCache findAndRemove(Query query) {
		return this.userCacheDao.findAndRemove(query);
	}

	public UserCache findAndModify(Query query, Update update) {

		return this.userCacheDao.findAndModify(query, update);
	}

	public void findAllAndRemove(Query query) {
		this.userCacheDao.findAllAndRemove(query);
	}
}
